package com.yuntcm.group6.med_booking.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuntcm.group6.med_booking.entity.Doctor;
import com.yuntcm.group6.med_booking.mapper.DoctorMapper;
import com.yuntcm.group6.med_booking.service.DoctorService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements DoctorService {
    @Override
    public List<Doctor> listAllDoctor(){
        return baseMapper.selectList(null);
    }

    @Override
    public List<Doctor> listAllDoctors() {
        return List.of();
    }



    @Override
    public List<Doctor> searchDoctors(String keyword,Integer deptId){
        LambdaQueryWrapper<Doctor>queryWrapper = new LambdaQueryWrapper<>();

        // 根据关键词搜索医生姓名、职称或简介
        if (keyword != null && !keyword.isEmpty()) {
            queryWrapper.like(Doctor::getTitle, keyword)  // 搜索职称
                    .or()
                    .like(Doctor::getIntro, keyword); // 搜索简介
            // 如果 Doctor 实体中有 userName 字段，可以添加：.or().like(Doctor::getUserName, keyword)
        }

        // 根据科室ID筛选
        if (deptId != null) {
            queryWrapper.eq(Doctor::getDeptId, deptId);
        }

        return baseMapper.selectList(queryWrapper);
    }
    }

